import { RouteConfig } from "vue-router";
import Layout from "@/layout/index.vue";
import { AuthModule } from "@/store/modules/auth";

let desktopUsername = () => AuthModule.authrole === 'system_admin' ? "userDesktopUser" : "userManage"

const userRouter: RouteConfig = {
  path: "/user",
  component: Layout,
  redirect: "/user/tenant_manager",
  name: "User",
  meta: {
    title: "userManage",
    routerRuleName: "User"
  },
  children: [
    {
      path: "tenant_manager",
      component: () => import("@/views/user/tenant_manager.vue"),
      name: "UserTenantManager",
      meta: {
        title: "userTenantManager",
        noCache: true,
        hidden: true
      }
    },
    {
      path: "desktop_user",
      component: () => import("@/views/user/desktop_user.vue"),
      name: "UserDesktopUser",
      meta: {
        title: desktopUsername,
        noCache: true,
        routerRuleName: "UserDesktopUser"
      }
    },
    {
      path: "tenant_manager_detail",
      component: () => import("@/views/user/tenant_manager_detail.vue"),
      name: "UserTenantManagerDetail",
      meta: {
        title: "userTenantManagerDetail",
        noCache: true,
        hidden: true,
        authrole: 'system_admin'
      }
    },
    {
      path: "system_manager_detail",
      component: () => import("@/views/user/system_manager_detail.vue"),
      name: "UserSystemManagerDetail",
      meta: {
        title: "userSystemManagerDetail",
        noCache: true,
        hidden: true,
        authrole: 'system_admin'
      }
    },
    {
      path: "desktop_user_detail",
      component: () => import("@/views/user/desktop_user_detail.vue"),
      name: "UserDesktopUserDetail",
      meta: {
        title: "userDesktopUserDetail",
        noCache: true,
        hidden: true
      }
    }
  ]
};

export default userRouter;
